﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using NicoView.Speech;
using NicoView.Model.Service;

namespace NicoView.View.Behaviors
{
    //
    // Action のターゲット要素をその親以外にしたい場合、クラスを
    // TriggerAction の代わりに TargetedTriggerAction から拡張します
    //
    public class EmptyTagRemoveAction : TagActionBase
    {
        public EmptyTagRemoveAction()
        {

        }

        protected override void OnInvoke(object msg)
        {

            if (this.TargetTags.Count > 1 &&
                      this.TargetTags.Contains(this.Target) &&
                    ! this.Target.IsEnabled())
            {

                this.TargetTags.Remove(this.Target);

                var lastTag = this.TargetTags[this.TargetTags.Count - 1];

                if (lastTag.IsEnabled())
                {
                    this.TargetTags.Add(new NicoViewNiconicoTag());
                }
            } 
        }
    }
}